<?php

namespace App\Models\Ly;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Agent extends Model
{
    use HasFactory;
    protected $table='agents';

    public static function getList($params)
    {
        $data=self::where($params)->paginate(5);
        return $data;
    }

    public static function getLists($params)
    {
        return self::where('name', 'like', '%' . $params . '%')->get();
    }

    public static function Getpaginate(){
        return self::query()->paginate(10);
    }


    //查看所有的经纪人
    static function GetAgent()
    {
        return self::where('is_del', '0')->get()->toArray();
    }

    //查找展示
    static function findBorder(array $where)
    {
        return self::where($where)->where('is_del', '0')->get()->toArray();
    }


    //添加经纪人
    static function border(array $params)
    {
        return self::create($params)->toArray();
    }

    //修改经纪人
    static function updateBroker(int $id, array $params)
    {
        return self::where('id', $id)->where('is_del', '0')->update($params);
    }

    //删除经纪人
    static function deleteBroker(int $id)
    {
        return self::where('id', $id)
            ->where('is_del', '0')
            ->update(['is_del' => '1']);
    }

}
